/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#include "./Macros/vLogMacros.h"
#include "./Window/ModalDialog/vErrorDialog.h"
#include "./Framework/Patterns/vSingletonReleaseManager.h"
#include "./Macros/vMemoryMacros.h"
#include "./App/vAbstractApp.h"

//START_MEMORY_TRACKING_SYSTEM;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, Vendetta::vInt iShowCmd) {
	LOGS_OPEN;
	LOGS_INFO("Starting application...");

	Vendetta::vAbstractApp* pApp = new Vendetta::vAbstractApp;

	try {
		pApp->Run();
	} catch (Vendetta::vFatalException& e) {
		Vendetta::vErrorDialog errDialog(hInstance, 0, e.ErrorMsg());
		errDialog.Exec();
	} catch (Vendetta::vException& e) {
		Vendetta::vErrorDialog errDialog(hInstance, 0, e.ErrorMsg());
		errDialog.Exec();
	} catch (...) {
		Vendetta::vErrorDialog errDialog(hInstance, 0, "Unknown exception.");
		errDialog.Exec();
	}
	vDelete(pApp);
	Vendetta::vSingletonReleaseManager::ReleaseSingletons();

	LOGS_INFO("Application closed successfully.");
	LOGS_CLOSE;

	return 0;
}

//STOP_MEMORY_TRACKING_SYSTEM;